package br.com.unieuro.servico;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import br.com.unieuro.dominio.Usuario;
import br.com.unieuro.facade.ManterUsuarioFacade;

import com.google.gson.Gson;

public class CriarJson {
	public String gerarJson() {

		Gson gson = new Gson();
		ManterUsuarioFacade facade = new ManterUsuarioFacade();
		ArrayList<Usuario> users = facade.pesquisarTodosUsuarios();

		String json = gson.toJson(users);
		
		try {
			//write converted json data to a file named "file.json"
			FileWriter writer = new FileWriter("d:\\file.json");
			writer.write(json);
			writer.close();
	 
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.out.println(json);

		return json;

	}
}


